Skip to content

Conversation

BobTheBuidler
Copy link
Contributor

This PR adds a new custom_op for PyObject_CallObject which is more efficient than PyObject_Call in cases where there are no kwargs. posarg-only use cases are already optimized but this is helpful for patterns such as fn(*args) or fn(a1, a2, *args)

This PR extends #19623 and #19629 , as this change will not be helpful until those PRs are merged.

I will rebase this PR on top as we go to keep everything as easy to review as possible.

star_result = self.primitive_op(list_tuple_op, [star_result], line)
if has_star2 and star2_result is None:
if has_star2 and star2_result is None and len(star2_keys) > 0:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might be able to get rid of has_star2 entirely with this PR

@BobTheBuidler BobTheBuidler changed the title [mypyc] feat: PyObject_CallObject op for fn(*args) [mypyc] feat: PyObject_CallObject op for fn(*args) fastpath Aug 11, 2025
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing -- can you have a look? Also, it would be good to check if the changes in this PR (and also the previous related PRs) are covered by run tests and add some if there are gaps in coverage.

@BobTheBuidler
Copy link
Contributor Author

IR tests are fixed, I still need to add run tests

@BobTheBuidler
Copy link
Contributor Author

I added the same new test cases on both this PR and on #19630

@BobTheBuidler BobTheBuidler requested a review from JukkaL August 24, 2025 15:17
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I verified that this makes a micro-benchmark 1.2x faster.

@JukkaL JukkaL merged commit d1dffe2 into python:master Aug 26, 2025
13 checks passed
@BobTheBuidler BobTheBuidler deleted the PyObject_CallObject branch August 26, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants